// 导入
import _fetch from '../utils/request'

// 封装获取新闻文章详情
function getDetailApi (id) {
  return _fetch({
    url: `/v1_0/articles/${id}`,
    needToken: true
  })
}

// 封装获取文章评论
function getCommentApi (data) {
  return _fetch({
    url: '/v1_0/comments',
    params: data
  })
}

// 添加评论或评论回复
function setCommentApi (data) {
  return _fetch({
    url: '/v1_0/comments',
    method: 'post',
    data: data,
    needToken: true
  })
}
// 封装关注用户
function getFollowingsApi (data) {
  return _fetch({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: data,
    needToken: true
  })
}

// 封装取消关注用户
function getFollowOffApi (id) {
  return _fetch({
    url: `/v1_0/user/followings/${id}`,
    method: 'DELETE',
    needToken: true
  })
}

// 封装对文章点赞
function getLikingsApi (data) {
  return _fetch({
    url: '/v1_0/article/likings',
    method: 'POST',
    data: data,
    needToken: true
  })
}

// 封装取消对文章点赞
function getOffLikingsApi (id) {
  return _fetch({
    url: `/v1_0/article/likings/${id}`,
    method: 'DELETE',
    needToken: true
  })
}

// 封装对文章喜欢
function getDislikesApi (data) {
  return _fetch({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: data,
    needToken: true
  })
}

// 封装取消对文章不喜欢
function getOffDislikesApi (id) {
  return _fetch({
    url: `/v1_0/article/dislikes/${id}`,
    method: 'DELETE',
    needToken: true
  })
}
// 取消收藏
function cancelCollectApi (id) {
  return _fetch({
    url: `/v1_0/article/collections/${id}`,
    method: 'DELETE',
    needToken: true
  })
}
// 收藏
function collectApi (data) {
  console.log(data)
  return _fetch({
    url: '/v1_0/article/collections',
    method: 'POST',
    needToken: true,
    data
  })
}

export {
  getDetailApi,
  getCommentApi,
  getFollowingsApi,
  getFollowOffApi,
  getLikingsApi,
  getOffLikingsApi,
  getDislikesApi,
  getOffDislikesApi,
  setCommentApi,
  cancelCollectApi,
  collectApi
}
